/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package isen.controller;

import isen.bean.Employee;
import isen.bean.EmployeeList;
import isen.database.Sensor;
import isen.database.SensorList;
import isen.ds.EmployeeDS;
import isen.hibernate.SensorHelper;
import java.util.List;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 *
 * @author isen
 */

@Controller
public class SensorController {
	private SensorHelper sensorHelper;
	private Jaxb2Marshaller jaxb2Mashaller;

    public SensorController() {
        this.sensorHelper = new SensorHelper();
        this.jaxb2Mashaller = new Jaxb2Marshaller();
    }
        
     	@RequestMapping(method=RequestMethod.GET, value="/sensors")
	public org.springframework.web.servlet.ModelAndView getEmployees() {
		List<Sensor> sensors = sensorHelper.getAllSensors();
                SensorList list = new SensorList(sensors); 
		return new org.springframework.web.servlet.ModelAndView("sensors", "sensors", list);
	}   
        
        @RequestMapping(method=RequestMethod.GET, value="/sensor/{id}")
	public org.springframework.web.servlet.ModelAndView getEmployee(@PathVariable String id) {
		
                Sensor sensor = sensorHelper.getSensorWithId(Integer.parseInt(id));  
		return new org.springframework.web.servlet.ModelAndView("sensor", "object", sensor);
	}
}
